#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll l, r;
ll dp[20][15][15][2][2][2];
ll num[15], tt;

ll dfs(ll pos, ll pre1, ll pre2, bool st, bool _8, bool _4, bool free)
{
    if (pos == 0) return st;
    if (free && dp[pos][pre1][pre2][st][_8][_4] != -1) return dp[pos][pre1][pre2][st][_8][_4];
    ll ans = 0;
    ll up = free ? 9 : num[pos];
    for (ll i = 0;i <= up;i++) {
        if ((_4 && i == 8) || (_8 && i == 4)) continue;
        ans += dfs(pos - 1, i, pre1, st || (pre1 == pre2 && pre1 == i), _8 || i == 8, _4 || i == 4, free || i < up);
    }
    if (free) dp[pos][pre1][pre2][st][_8][_4] = ans;
    return ans;
}

ll f(ll x)
{
    tt = 0;
    while (x) {
        num[++tt] = x % 10;
        x /= 10;
    }
    memset(dp, -1, sizeof dp);
    ll res = 0;
    for (int i = 1;i <= num[tt];i++)
        res += dfs(tt - 1, i, 0, 0, i == 8, i == 4, i < num[tt]);
    return res;
}

void solve()
{
    cin >> l >> r;
    if (l == 10000000000)
        cout << f(r) - f(l) + 1;
    else cout << f(r) - f(l - 1);
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}